#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
struct Point {
  int x, y;
  bool operator==(const Point& o) const { return x == o.x && y == o.y; }
  bool operator!=(const Point& o) const { return !(*this == o); }
};
struct Segment {
  Point p1, p2;
} a[5];
ll s2(Point A, Point B) {
  ll dx = A.x - B.x, dy = A.y - B.y;
  return dx * dx + dy * dy;
}
bool same_line(Point A, Point B, Point C) {
  ll x1 = B.x - A.x, y1 = B.y - A.y;
  ll x2 = C.x - A.x, y2 = C.y - A.y;
  return x1 * y2 == y1 * x2;
}
bool pos_in(int x, int y, int z) {
  if (x > z) swap(x, z);
  return x <= y && y <= z;
}
bool split(Point A, Point B, Point C) {
  if (!same_line(A, B, C)) return false;
  if (!pos_in(A.x, C.x, B.x)) return false;
  if (!pos_in(A.y, C.y, B.y)) return false;
  ll x = s2(A, B), y = 25 * s2(A, C);
  return y >= x && y <= 16 * x;
}

bool check(int i, int j, int k) {
  Point A, B, C;
  if (a[i].p1 == a[j].p1)
    A = a[i].p1, B = a[i].p2, C = a[j].p2;
  else if (a[i].p1 == a[j].p2)
    A = a[i].p1, B = a[i].p2, C = a[j].p1;
  else if (a[i].p2 == a[j].p1)
    A = a[i].p2, B = a[i].p1, C = a[j].p2;
  else if (a[i].p2 == a[j].p2)
    A = a[i].p2, B = a[i].p1, C = a[j].p1;
  else
    return false;
  if (same_line(A, B, C)) return false;  // ang == 0
  ll x = s2(A, B), y = s2(A, C), z = s2(B, C);
  if (z > x + y) return false;  // angle > 90

  if (split(A, B, a[k].p1) && split(A, C, a[k].p2)) return true;
  if (split(A, B, a[k].p2) && split(A, C, a[k].p1)) return true;
  return false;
}
void solve() {
  rep(i, 1, 3) cin >> a[i].p1.x >> a[i].p1.y >> a[i].p2.x >> a[i].p2.y;
  bool res = check(1, 2, 3) || check(1, 3, 2) || check(2, 3, 1);
  if (res)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}